package com.wenhao.tencent;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author Wenhao Tong
 * @create 2021-08-22 20:19
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        final long MOD = 1000000007;
        for (int i = 0;i < T;i++) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int j = 0;j < n;j++) {
                a[j] = scanner.nextInt();
            }
            Arrays.sort(a);
            long sum = Arrays.stream(a).sum();
            for (int j = a.length - 1;j > -1;j--) {
                sum = (sum + (a[j] * (j + 1) * j / 2)) % MOD;
            }
            System.out.println(sum);
        }
    }
}
